package com.gxd.dao.impl;

import com.gxd.dao.OrderDetailDao;
import com.gxd.domain.OrderDetail;
import com.gxd.util.DBUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.Connection;
import java.sql.SQLException;

public class OrderDetailDaoImpl implements OrderDetailDao {
    @Override
    public void insertOrderDetail(OrderDetail orderDetail) {
        QueryRunner queryRunner = new QueryRunner();
        Connection connection = DBUtils.getConnection();
        String sql=" insert into tb_orderdetail values(null,?,?,?,?) ";
        Object[] params={ orderDetail.getOid(),orderDetail.getPid(),orderDetail.getNum(),orderDetail.getMoney()};
        try {
            queryRunner.update(connection,sql,params);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
